/* 
定义带getter和setter的属性value
功能类似于defineProperty
*/

class RefImpl {
  constructor (value) {
    this._value = value
  }

  get value () {
    console.log('监视到读取value')
    return this._value
  }

  set value (newValue) {
    if (newValue!==this._value) {
      this._value = newValue
      console.log('监视到更新value')
    }
    
  } 
}


function ref(value) {
  return new RefImpl(value)
}


const count = ref(2)
console.log(count)
// 读取value
console.log(count.value)
// 更新value
count.value = 3
console.log(count.value)



